import type { App } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persist'
const store = createPinia()
// 如果是开发环境，可以在控制台直接访问store，方便调试。
if (process.env.NODE_ENV === 'development') {
  window['_STORE'] = store
}
store.use(piniaPluginPersist)

export function setupStore(app: App<Element>) {
  app.use(store)
}

export { store }
